function sum(a, b) {
    a = `0${a}`, b = `0${b}`
    let arrA = a.split(''), 
        arrB = b.split(''),
        res = [],
        temp = '',
        carry = 0,
        distance = a.length - b.length,
        len = distance > 0 ? a.length : b.length

    if(distance > 0) {
        for(let i = 0; i < distance; i++) {
            arrB.unshift('0')
        }
    } else {
        for(let i = 0; i > distance; i--) {
            arrA.unshift('0')
        }
    }

    for(let i = len - 1; i >= 0; i--) {
        temp = Number(arrA[i]) + Number(arrB[i]) + carry
        if(temp >= 10) {
            carry = 1
            res.unshift((temp + '')[1])
        } else {
            carry = 0
            res.unshift(temp)
        }
    }
    res = res.join('').replace(/^0/, '')
    return res
}

// var number1 = 10000000000000000000000000 + 11111111111111111111111111   //理论上number1的值应该是21111111111111111111111111（javascript中会表示为科学计数法：2.111111111111111e+25）
// var number2 = '21111111111111111111111111'
// console.log(number1 === number2)  //true
var number1 = '10000000000000000000000000'
var number2 = '11111111111111111111111111'

console.log(sum(number1, number2))
